package com.hyzx.qbasic.admin.domain.repository.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hyzx.qbasic.admin.model.po.SysParamPO;
import com.hyzx.qbasic.admin.model.dto.KeyValuePair;
import com.hyzx.qbasic.admin.domain.dao.SysParamMapper;
import com.hyzx.qbasic.admin.domain.repository.ISysParamRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by 黄江华 on 2018/7/20
 */

@Repository
public class SysParamRepositoryImpl implements ISysParamRepository {

    @Autowired
    private SysParamMapper paramMapper;

    @Override
    public PageInfo<SysParamPO> getPagedParamList(int pageNum, int pageSize, String pType) {
        PageInfo pageInfo = PageHelper.startPage(pageNum, pageSize)
                .doSelectPageInfo(() -> paramMapper.getPagedParamList(pType));

        return pageInfo;
    }

    @Override
    public boolean addParam(SysParamPO param) {
        return paramMapper.addParam(param) > 0;
    }

    @Override
    public boolean deleteParam(List<Integer> pIdList) {
        return paramMapper.deleteParam(pIdList) > 0;
    }

    @Override
    public SysParamPO getParamInfo(int pId) {
        return paramMapper.getParamInfo(pId);
    }

    @Override
    public boolean editParam(SysParamPO param) {
        return paramMapper.editParam(param) > 0;
    }

    @Override
    public List<KeyValuePair> getParamListByType(String pType) {
        return paramMapper.getParamListByType(pType);
    }
}
